/*
 * @Date: 2023-07-31 01:18:13
 * @LastEditors: zhangsongwei
 * @LastEditTime: 2023-08-06 02:42:29
 * @FilePath: /z/src/pages/dashbord/index.tsx
 * @description:
 */
import React, { useEffect, useState } from "react";
import { Layout, Tabs } from "antd";
import {} from "../../urls/p";
import "./index.less";

import { getBasic } from "../../urls/p";
import MainView from "./main";
import SubView from "./sub";
import User from "./user";
import Auth from "./auth";
import First from "./first";
import Info from "./info";

const { TabPane } = Tabs;

export default () => {
  const [activeTab, setActiveTab] = useState("1");
  const [classId, setClassId] = useState("");
  const [subClassId, setSubClassId] = useState("");
  const onChange = (key: string) => {
    if (+key === 3) {
      classId && setActiveTab(key);
    } else if (+key === 4) {
      subClassId && setActiveTab(key);
    } else {
      setActiveTab(key);
    }
  };
  return (
    <div className="">
      <Tabs activeKey={activeTab} onChange={onChange}>
        <TabPane tab="Dashboard" key="1">
          <First />
        </TabPane>
        <TabPane tab="main" key="2">
          <MainView
            onClick={(r) => {
              setClassId(r.classId);
              setActiveTab("3");
            }}
          />
        </TabPane>
        <TabPane tab="sub" key="3">
          <SubView
            onClick={(r) => {
              setSubClassId(r.subClassId);
              setActiveTab("4");
            }}
            classId={classId}
          />
        </TabPane>
        <TabPane tab="Info" key="4">
          <Info subClassId={subClassId} />
        </TabPane>
        <TabPane tab="user" key="5">
          <User />
        </TabPane>
        <TabPane tab="Auth" key="6">
          <Auth />
        </TabPane>
      </Tabs>
    </div>
  );
};
